<?php
class Post_CommentController extends Zendvn_Controller_Action{
	
	public function init(){
		parent::init();
		$this->view->main = FALSE;
		
	}
	
	public function indexAction(){
	
	}
	
	public function insertAction(){
		
		if ($this->getRequest()->isPost()){
						
			$idpost = $_POST["idpost"];
			
			$content = $_POST["content"];
			
			$storage = new Zend_Auth_Storage_Session();
			$data = $storage->read();
			$comment = new Post_Model_Comment();
			
			if(isset($idpost) && isset($content)){
				
				$arr = array(
						"postid"=>$idpost,
						"userid"=>$data->id,						
						"content"=>$content,
						"createdate"=>date('Y-m-d h:i:s',time()),										
				);	
				
				$idcomment = $comment->insertComment($arr);
				
				$this->view->content = $content;
				
				
				
				
			}
			
		}
		
	}
	
	public function updateAction(){
		
		if ($this->getRequest()->isPost()){
			
			$idmedia = $_POST["idmedia"];
			
			
			$storage = new Zend_Auth_Storage_Session();
			$data = $storage->read();
			$media = new Post_Model_Media();
			if(isset($idmedia)){
				
				$arr = array(
						"id"=>$idmedia,
						"userid"=>$data->id,						
						"postid"=>0,										
				);	
				
				$media->updateMedia($arr);
			}
			
		}
	}
	
}